<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<sec:authentication property="principal" var="currentPrincipal" scope="page"/>

<div class="modal-dialog ms-modal-dialog" style="width: 800px;">
  <div class="modal-content">
  
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <h4 class="modal-title">修改司机个人信息</h4>
    </div>

    <div class="modal-body">

      <form class="form-horizontal ms-form form-personal-info" method="POST" action="${ctx.host}/drivers/${driver.id}/edit-basic" data-validate="true">
      
        <input type="hidden" name="_method" value="PATCH">
        <input type="hidden" name="driverId" value="${driver.id}">
  
        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-2"><span class="color-red">*</span>姓名：</label>
          <div class="col-xs-3 pull-left">
            <c:choose>
              <c:when test="${not driver.status.qualified}">
  		          <input type="text" name="name" class="form-control" value="${driver.name}" data-validate="required" tabindex="3" autocomplete="off"/>
              </c:when>
              <c:otherwise>
                <label class="control-label">${driver.name}</label>
                <input type="hidden" name="name" class="form-control" value="${driver.name}"/>
              </c:otherwise>
            </c:choose>
          </div>
          
          <label class="control-label col-xs-2"><span class="color-red">*</span>性别：</label>
          <div class="col-xs-3 pull-left">

            <c:if test="${driver.status.qualified}">
              <select name="gender" class="select2 form-control" tabindex="4" data-validate="required">
                <option value="${driver.gender}" selected>${driver.gender eq 60 ? '男' : driver.gender eq 61 ? '':''}</option>
              </select>
            </c:if>

            <c:if test="${not driver.status.qualified}">
              <select name="gender" class="select2 form-control" tabindex="4" data-validate="required">
                <option></option>
                <option value="60" ${driver.gender eq 60 ? 'selected' : ''}>男</option>
                <option value="61" ${driver.gender eq 61 ? 'selected' : ''}>女</option>
              </select>
            </c:if>
          </div>
        </div>
  
        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-2"><span class="color-red">*</span>身份证号：</label>
          <div class="col-xs-3 pull-left">
            <c:choose>
              <c:when test="${not driver.status.qualified}">
  	            <input type="text" name="citizenCode" class="form-control" value="${driver.citizenCode}" data-validate="required" tabindex="7" autocomplete="off"/>
              </c:when>
              <c:otherwise>
                <label class="control-label">${driver.citizenCode}</label>
                <input type="hidden" name="citizenCode" class="form-control" value="${driver.citizenCode}" />
              </c:otherwise>
            </c:choose>
          </div>
          
          <label class="control-label col-xs-2"><span class="color-red">*</span>出生日期：</label>
          <div class="col-xs-3 pull-left">
            <c:choose>
              <c:when test="${not driver.status.qualified}">
                <input type="text" name="birthday" class="form-control date" value="<fmt:formatDate value="${driver.birthday}" pattern="yyyy-MM-dd"/>" data-validate="required" tabindex="6" autocomplete="off"/>
              </c:when>
              <c:otherwise>
                <label class="control-label"><fmt:formatDate value="${driver.birthday}" pattern="yyyy-MM-dd"/></label>
                <input type="hidden" name="birthday" class="form-control date" value="<fmt:formatDate value="${driver.birthday}" pattern="yyyy-MM-dd"/>" />
              </c:otherwise>
            </c:choose>
          </div>
        </div>
        
        <div class="form-group  ms-form-group">
		  <label class="control-label col-xs-2"><span class="color-red">*</span>手机号码：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="mp" class="form-control" value="${driver.mp}" data-validate="required|mobile" tabindex="22" autocomplete="off"/>
          </div>
  				
          <label class="control-label col-xs-2"><span class="color-red">*</span>工号：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="code" class="form-control" value="${driver.code}" data-validate="required" tabindex="2" autocomplete="off"/>
          </div>
        </div>
  
        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-2"><span class="color-red">*</span>现任职务：</label>
          <div class="col-xs-3 pull-left">
            <select name="dutyId" class="select2 form-control" tabindex="8">
              <option></option>
              <c:forEach items="${enums['DriverDuty']}" var="duty">
                <option value="${duty.id}" ${driver.dutyId eq duty.id ? 'selected' : ''}>${duty.description}</option>
              </c:forEach>
            </select>
          </div>
          
          <label class="control-label col-xs-2"><span class="color-red">*</span>驾龄：</label>
          <div class="col-xs-3 pull-left">
            <input type="text" name="drivingAge" class="form-control" value="${driver.drivingAge}" data-validate="required|number" tabindex="22" autocomplete="off"/>
          </div>
        </div>
  
        <div class="form-group  ms-form-group">
        	<label class="control-label col-xs-2"><span class="color-red">*</span>劳务合同签署方：</label>
          <div class="col-xs-3 pull-left">
            <select name="contractParty" data-validate="required" class="select2 form-control" tabindex="23">
              <option></option>
              <option value="01" ${driver.contractParty eq '01' ? 'selected' : ''}>公司</option>
              <option value="02" ${driver.contractParty eq '02' ? 'selected' : ''}>中介</option>            
            </select>
          </div>
          
          <label class="control-label col-xs-2"><span class="color-red">*</span>准驾车型</label>
          <div class="col-xs-3 pull-left">
            <select name="drivingType" class="select2 form-control">
              <option></option>
            	<option value="01" ${driver.drivingType == '01' ? 'selected' : ''}>A1</option>
              <option value="02" ${driver.drivingType == '02' ? 'selected' : ''}>A2</option>
              <option value="03" ${driver.drivingType == '03' ? 'selected' : ''}>B2</option>
              <option value="04" ${driver.drivingType == '04' ? 'selected' : ''}>B1</option>
              <option value="05" ${driver.drivingType == '05' ? 'selected' : ''}>C1</option>
            </select>
          </div>
        </div>
        
        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-2"><span class="color-red">*</span>是否激活（FMS）：</label>
          <div class="col-xs-3 pull-left">
            <select name="active" class="select2 form-control" tabindex="7">
              <option></option>
              <option value="true" ${driver.active ? 'selected' : ''}>是</option>
              <option value="false" ${not driver.active  ? 'selected' : ''}>否</option>
            </select>
          </div>
        </div>
  
        <div class="modal-footer ms-modal-footer">
          <button type="submit" class="btn ms-btn btn-primary btn-submit">确定</button>
          <button type="button" class="btn ms-btn ms-btn-gary" data-dismiss="modal">取消</button>
        </div>
  
      </form>
      
    </div>

  </div>
</div>
  
<script type="text/javascript">
  $(document).ready(function() {
    
    $('select[name="gender"]').select2({
      placeholder: '请选择性别',
      minimumResultsForSearch: -1,
      allowClear: true,
    });

    $('select[name="dutyId"]').select2({
      placeholder: '请选择现任职务',
      minimumResultsForSearch: -1,
      allowClear: true,
    });
    
    $('select[name=drivingType]').select2({
      placeholder: '请选择准驾车型',
      minimumResultsForSearch: -1,
      allowClear: true,
    });
    
    $('select[name="contractParty"]').select2({
      placeholder: '请选择劳务合同签署方',
      minimumResultsForSearch: -1,
      allowClear: true
    });
    
    $('select[name=active]').select2({
      placeholder: '请选择是否激活',
      minimumResultsForSearch: -1,
      allowClear: true,
    });
    
  });
</script>